

#import "NVSimpleWebViewController.h"


@implementation NVSimpleWebViewController

@synthesize url;
@synthesize title;
@synthesize openExternal;

- (id)init {
	return [self initWithNibName:@"SimpleWebView" bundle:[NSBundle mainBundle]];
}
//
//- (BOOL)handleWithURLAction:(NVURLAction *)urlAction
//{
//    NSString *pUrl = [urlAction stringForKey:@"url"];
//	
//	if (pUrl.length < 1) {
//		return NO;
//	}
//
//    NSString *aURL = [urlAction stringForKey:@"url"];
//    self.url = [NSURL URLWithNoNilString:aURL];
//    self.title = [urlAction stringForKey:@"title"];
//    NSString *oe = [urlAction stringForKey:@"openexternal"];
//    self.openExternal = [@"1" isEqual:oe] || [@"true" isEqual:oe];
//    
//    return [super handleWithURLAction:urlAction];
//}

- (BOOL)webView:(UIWebView *)web shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
	if(self.openExternal) {
		if([[request URL] isEqual:url])
			return YES;
		
		if (0/*******![NVTask canJumpApp]*/) {
			return NO;
		}
		[[UIApplication sharedApplication] openURL:[request URL]];
		return NO;
	} else {
		return [super webView:web shouldStartLoadWithRequest:request navigationType:navigationType];
	}
}

- (void)viewDidLoad {
	[super viewDidLoad];
	if([title length] > 0) {
		[super setTitleStr:title];
	}
	[webView loadRequest:[NSURLRequest requestWithURL:url]];
}

- (void)dealloc {
    self.url = nil;
    self.title = nil;
    [super dealloc];
}

@end
